/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.iamk.database;

import java.sql.*;
import org.apache.commons.dbutils.DbUtils;


public class DataPreprocessor {

    public Connection mConnection = null;
    public PreparedStatement mStmt = null;
    public ResultSet mRs = null;
    public String mstrLogID;

    public Connection getConnection() throws Exception {
        return mConnection;
    }

    public DataPreprocessor() {
    }

    public void open() throws Exception {
        if (mConnection == null || mConnection.isClosed()) {
            mConnection = ConnectionFactory.getConnection();
        }
    }

    public void close() throws SQLException {
        DbUtils.closeQuietly(mConnection);
    }

    public void close(ResultSet rs, PreparedStatement stmt) throws SQLException {
        close(rs);
        close(stmt);
    }

    public void close(PreparedStatement stmt, Connection connection) throws SQLException {
        close(stmt);
        close();
    }

    public void close(Connection connection) throws SQLException {
        DbUtils.closeQuietly(connection);
    }

    public void close(PreparedStatement stmt) throws SQLException {
        DbUtils.closeQuietly(stmt);
    }

    public void close(Statement stmt) throws SQLException {
        DbUtils.closeQuietly(stmt);
    }

    public void close(ResultSet rs) throws SQLException {
        DbUtils.closeQuietly(rs);
    }

    public void close(Connection connection, PreparedStatement stmt,
            ResultSet rs) throws SQLException {
        close(rs);
        close(stmt);
        close();
    }
}
